from rest_framework import serializers
from update_app.models import Update

class UpdateSerializer(serializers.ModelSerializer):
    '''更新课程序列化器'''
    create_time = serializers.DateTimeField(format='%Y-%m-%d')
    class Meta:
        model = Update
        fields = ['id','name','create_time','update_type']

class UpdateDetailSerializer(serializers.ModelSerializer):
    '''更新课程序列化器'''
    course_name = serializers.CharField(source='course.name')
    stage_name = serializers.CharField(source='stage.name')
    create_time = serializers.DateTimeField(format='%Y-%m-%d')
    class Meta:
        model = Update
        fields = '__all__'